#include "Console.h"

namespace mp_base { namespace console {

	const string Console::CONSOLE_MESSAGE_PREFIX = "} ";
	const string Console::CONSOLE_ERROR_PREFIX = "Error} ";

	void Console::WriteMessage(const string msg){
		while (!TryLock()){ Pause(1); }
		std::cout << "\n" << CONSOLE_MESSAGE_PREFIX << msg;
		m_consoleMessages.push_back(msg);
		Unlock();
	}
	void Console::WriteMessage(const char* msg){
		while (!TryLock()){ Pause(1); }
		std::cout << "\n" << CONSOLE_MESSAGE_PREFIX << msg;
		m_consoleMessages.push_back(msg);
		Unlock();
	}
	void Console::WriteMessage(const Event& msg){
		while (!TryLock()){ Pause(1); }
		std::cout << "\n" << CONSOLE_MESSAGE_PREFIX << 
			msg.GetEventMessage();
		m_consoleMessages.push_back(msg.GetEventMessage());
		Unlock();
	}

	void Console::WriteError(const string er){
		while (!TryLock()){ Pause(1); }
		std::cout << "\n" << CONSOLE_ERROR_PREFIX << er;
		m_consoleErrors.push_back(er);
		Unlock();
	}
	void Console::WriteError(const char* er){
		while (!TryLock()){ Pause(1); }
		std::cout << "\n" << CONSOLE_ERROR_PREFIX << er;
		m_consoleErrors.push_back(er);
		Unlock();
	}
	void Console::WriteError(const Error& er) {
		while (!TryLock()){ Pause(1); }
		std::cout << "\n" << CONSOLE_ERROR_PREFIX <<
			er.GetMessage();
		m_consoleErrors.push_back(er.GetMessage());
		Unlock();
	}


}}